// ServerManager.cpp: implementation of the CServerManager class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "DataPicker.h"
#include "ServerManager.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif


CServerManager g_serverMan;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CServerManager::CServerManager()
{
	m_number = 0;
	InitAll();
}

CServerManager::~CServerManager()
{
	InitAll();
}



int CServerManager::InitAll()
{
	for (int i=0;i<m_number;i++)
	{
		m_servers[i].server_url[0] = 0;
		m_servers[i].port = 0;
		m_servers[i].login_name[0] = 0;	
		m_servers[i].login_passwd[0] = 0;	
	}
	m_number = 0;
	return m_number;
}


int CServerManager::Add(stServerNode server)
{
	int result = 0;
	if (m_number>=MAX_SERVER_NUMBER)
	{
		result =  -1;
	}
	else
	{
		memcpy(&(m_servers[m_number]),&server,sizeof(server));
		m_number++;
		
	}
	return m_number;
}


int CServerManager::GetCount()
{
	return m_number;
}

stServerNode CServerManager::GetItem(int i)
{
	return m_servers[i];
}
